package com.edu.exam.enums.core;

/**
 * 教室可用性状态枚举
 */
public enum RoomAvailabilityStatus {
    AVAILABLE("AVAILABLE", "可用"),
    UNAVAILABLE("UNAVAILABLE", "不可用"),
    UNDER_MAINTENANCE("UNDER_MAINTENANCE", "维护中"),
    RESERVED("RESERVED", "已预约"),
    OCCUPIED("OCCUPIED", "已占用"),
    IN_USE("IN_USE", "使用中"),
    TEMPORARILY_UNAVAILABLE("TEMPORARILY_UNAVAILABLE", "暂时不可用"),
    PERMANENTLY_UNAVAILABLE("PERMANENTLY_UNAVAILABLE", "永久不可用");

    private final String code;
    private final String description;

    RoomAvailabilityStatus(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static RoomAvailabilityStatus fromCode(String code) {
        for (RoomAvailabilityStatus status : values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("Unknown room availability status code: " + code);
    }
}